// const express require('express')
const User = require('./db/user.js')
const md5 = require('md5-node')

module.exports = function(cookie){
	return new Promise((resolve,reject) => {
		if(cookie.account){
			const pw = md5(cookie.pw+'hey!')
			User.findOne({
				account:cookie.account,
				password:pw
			})
			.then(user => {
				if(!user){
					reject({message:'cookieCheck:账号或密码不正确'})
				}else{
					resolve(user)
				}
			})
		}else{
			reject('请登录')
		}
	})

}